import request from '@/utils/request'

export function getUserList(role: string, params: any) {
    return request({
        url: `/api/users/${role}`,
        method: 'get',
        params
    });
}

export function createUser(role: string, data: any) {
    return request({
        url: `/api/users/${role}`,
        method: 'post',
        data
    });
}

export function updateUser(role: string, data: any) {
    return request({
        url: `/api/users/${role}/${data.id}`,
        method: 'put',
        data
    });
}

export function deleteUser(role: string, id: number) {
    return request({
        url: `/api/users/${role}/${id}`,
        method: 'delete'
    });
}

export function batchDeleteUser(role: string, ids: number[]) {
    return request({
        url: `/api/users/${role}/batch`,
        method: 'post',
        data: ids
    });
}

export function getStudentById(studentId: number) {
    return request({
        url: `/api/users/students/${studentId}`,
        method: 'get'
    });
}

// 查询家长绑定学生个数
export function getParentBindingsCount(parentId: number) {
    return request({
        url: `/api/parents/${parentId}/bindings/count`,
        method: 'get'
    });
}
